<?php

$dbconn = pg_connect ("host=localhost port=5432 dbname=postgres user=postgres password=leliput93");

// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

$result = pg_query($dbconn, "SELECT * from supermarket.akun WHERE username = '$myusername' AND password = '$mypassword'");

$count = pg_num_rows($result);

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
header("location:main_login.php");
}
?>